#ifndef DYN_ROOTS_MULTIDIM_STAPLUS
#define DYN_ROOTS_MULTIDIM_STAPLUS

#include "dyn_roots.h"
#include "../utilities/dyn_multifunctor_multiMaps.h"
#include "dyn_roots_multiDim_sta.h"

/*! \brief STA with better local convergence.
 *
 * This class defines the STA variant
 * developed by Davidchack and Lai in
 * 1999. It is a globally convergent scheme
 * with local quadratic convergence (near
 * an orbit point).
 */

class STAPlus : public MultiSTA
{
public:
    /*! Constructor of the STAPlus variant.
     * It calls the MultiSTA constructor.*/
    STAPlus(MultiMaps& map,
            colvec init,
            const double tol,
            const double tol2,
            const double para,
            const int p,
            const int Nmax);

    /*! @name Accessor functions.
     * Specific accessor functions for STAPlus.
     */
    //@{
    int getPeriod(){return period;}
    double getTolerance2(){return tolerance2;}

    void setPeriod(int p){period = p;}
    void setTolerance2(double tol2){tolerance2 = tol2;}
    //@}

    /*! Reimplementation of the solve() function. */
    int solve();

    /*! Calculation of the correction. */
    colvec computeCorrection(colvec init, mat C, double para, int p, int dim);

protected:
    /*! @name Specialized variables.*/
    //@{
    int period;
    double tolerance2;
    //@}
};

#endif // DYN_ROOTS_MULTIDIM_STAPLUS
